package despachador.pagina;

import gestores.pagina.GestorPrincipal;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.*;
import javax.servlet.http.*;
import util.FuncionServlets;

public class Articulo extends HttpServlet {
    private static final String CONTENT_TYPE = "text/html; charset=windows-1252";

    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    public void processRequest(HttpServletRequest request,
                               HttpServletResponse response) throws ServletException, IOException {
        
        // Guardar los parametros
        FuncionServlets.obtenerParametros(request, response, true);
        
        String url = "/micrositios/" + (String) request.getAttribute("nomMicro");
        
        // Especificamos que pagina se coloca en cada parte del layout
        request.setAttribute("1", url + "/encabezado.jsp");
        request.setAttribute("2", url + "/destacado.jsp");
        request.setAttribute("3", url + "/buscador.jsp");
        request.setAttribute("4", "/vistas/pagina/menuizq.jsp");
        request.setAttribute("5", url + "/bannerizq.jsp");
        
        request.setAttribute("6", "/vistas/pagina/articulo.jsp");
        
        request.setAttribute("7", "/vistas/pagina/visitados.jsp");
        //request.setAttribute("7", url + "/login.jsp");
        request.setAttribute("8", "/vistas/pagina/login.jsp");
        request.setAttribute("9", "/vistas/pagina/rss.jsp");
        request.setAttribute("10", url + "/pie.jsp");
        
        dispatch(request, response, "/compositor/pagina/seiscuerpos.jsp");
    }    

    public void doGet(HttpServletRequest request, 
                      HttpServletResponse response) throws ServletException, IOException {
        processRequest(request, response);
    }

    public void doPost(HttpServletRequest request, 
                       HttpServletResponse response) throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * dispatcher method
     */
    protected void dispatch(HttpServletRequest request,
            HttpServletResponse response, String page) 
            throws javax.servlet.ServletException, 
            java.io.IOException {
        RequestDispatcher dispatcher = 
            getServletContext(). 
            getRequestDispatcher(page);
        dispatcher.forward(request, response);
    }
}
